package com.action;

import java.util.List;

import com.dto.UserProfileDTO;
import com.opensymphony.xwork2.ActionSupport;
import com.service.UserProfileService;

public class UserProfileAction extends ActionSupport
{
	private String name;
	private int mobile;
	private String email;
	private String panNo;
	private String dob;
	private String occupation;
	private String address;
	private int pinCode;
	private String country;
	private String state;
	private String city;
	private String operation;
	private List list;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getMobile() {
		return mobile;
	}
	public void setMobile(int mobile) {
		this.mobile = mobile;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPanNo() {
		return panNo;
	}
	public void setPanNo(String panNo) {
		this.panNo = panNo;
	}
	public String getDob() {
		return dob;
	}
	public void setDob(String dob) {
		this.dob = dob;
	}
	public String getOccupation() {
		return occupation;
	}
	public void setOccupation(String occupation) {
		this.occupation = occupation;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public int getPinCode() {
		return pinCode;
	}
	public void setPinCode(int pinCode) {
		this.pinCode = pinCode;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getOperation() {
		return operation;
	}
	public void setOperation(String operation) {
		this.operation = operation;
	}
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}
	
	@Override
	public String execute() throws Exception 
	{
		UserProfileDTO dto = new UserProfileDTO();
		UserProfileService service = new UserProfileService();
		
		if("Add".equalsIgnoreCase(operation))
		{
			dto.setName(name);
			dto.setMobile(mobile);
			dto.setEmail(email);
			dto.setPanNo(panNo);
			dto.setAddress(address);
			dto.setDob(dob);
			dto.setOccupation(occupation);
			dto.setAddress(address);
			dto.setCountry(country);
			dto.setState(state);
			dto.setCity(city);
			service.add(dto);
			return "add";
		}
		
		if("list".equalsIgnoreCase(operation))
		{
			list = service.getList();
			return "list";
		}
		return SUCCESS;
	}	
}
